/* ==========================================================
 * Cognitive psych experiment
 * ==========================================================
 */
 
// ==========================================================
// Result storage; NEED TO INCREMENT FOR EVERY SUBJECT 
// ==========================================================

String subject				= "00";
boolean write_data			= true;
boolean randomize_stimuli		= true;
boolean training				= false;



































// ==========================================================
// Stimuli list file and directory containing trees
// ==========================================================
String stimuli_list_file			= "data/experiment_stimuli_FULL.txt";
String stimuli_list_training		= "data/experiment_stimuli_TRAINING.txt";

String tree_directory			= "trees_full";
String tree_directory_training		= "trees_training";

// ==========================================================
// color
// ==========================================================
color HILIGHT_COLOR			= #FF8686;

static final int FOCUS_ELLIPSE = 25;

// time
int theTime = 0;
static final int BUFFER_SIZE		= 1024*1024;
int treeDepth = -1;
int maxChild = -1;

// stimuli data
StimuliList stimuliData = null;
Experiment experiment = null;

// state information
boolean dataSaved = false;

float getTime()
{
	return (float) theTime / 1000.0;
}

void setup()
{
	// open processing window
	size(1280, 1024);
	smooth();

	if (training)
	{
		println("\n*** Training *** \n");
		stimuli_list_file = stimuli_list_training;
		tree_directory = tree_directory_training;
	}
	
	// load the stimuli
	stimuliData = new StimuliList(stimuli_list_file);
	
	// create experiment
	experiment = new Experiment( stimuliData );
	

}

void draw()
{
	background(0);
	
	// update time
	theTime = millis();
	
	
	// render the experiment
	boolean done = experiment.render();
	
	if (done && write_data && !dataSaved)
	{
		experiment.writeResults( "data/results/subject" + subject + "/results.txt" );
		experiment.writeLog( "data/results/subject" + subject + "/log.txt" );
		experiment.writeMachineResults( "data/results/subject" + subject + "/machine-results.txt" );
		
		dataSaved = true;
	}
}


void keyPressed()
{
	experiment.keyPressed();
}
